home *** CD-ROM | disk | FTP | other *** search
- /* $Id: COMTwen.cpp 1.4 1997/04/05 02:39:04 damien Exp $ */
-
- ////////////////////////////////////////////////////////////////////////
- // Tweener Example : ????? //
- //--------------------------------------------------------------------//
- // Implementation of the Tweener Interface //
- ////////////////////////////////////////////////////////////////////////
-
-
- #ifndef __COMTWEN__
- #include "COMTWEN.h"
- #endif
-
- #ifndef __TWENDLL__
- #include "TWENDLL.h"
- #endif
-
- #ifndef __3DCOFAIL__
- #include "3DCoFail.h"
- #endif
-
- #include "Math.h"
- #ifndef M_PI
- #define M_PI 3.141592657
- #endif
-
-
- #undef INTERFACE
- #define INTERFACE Tweener
- // Constructor / Destructor of the C++ Object :
- Tweener::Tweener() {
- fCRef=0; // Reference Counter
- // Data initialisation :
- fData.fNbOsc = 5;
- fData.fExpCoef = 1.0;
- fExpCoef = 1.0;
- fCosCoef = 2* (fData.fNbOsc+0.25) * M_PI;
- }
-
- Tweener::~Tweener() {
- global_count_Obj--;
- }
-
- // IUnknown Interface :
- HRESULT Tweener::QueryInterface(THIS_ REFIID riid,LPVOID* ppvObj) {
- *ppvObj=NULL;
-
- // The Tweener knows the interfaces of the parent Objects
- if (IsEqualIID(riid, IID_IUnknown))
- *ppvObj=(LPVOID)this;
- else if (IsEqualIID(riid, IID_I3DExTweener))
- *ppvObj=(LPVOID)this;
- else if (IsEqualIID(riid, IID_I3DExDataExchanger))
- *ppvObj=(LPVOID)this;
- else if (IsEqualIID(riid, IID_I3DExtension))
- *ppvObj=(LPVOID)this;
-
- // we must add reference if we return an interface
- if (*ppvObj!=NULL) {
- ((LPUNKNOWN)*ppvObj)->AddRef();
- return NOERROR;
- }
- else {
- return ResultFromScode(E_NOINTERFACE);
- }
- }
-
- ULONG Tweener::AddRef(THIS) {
- return fCRef++;
- }
-
- ULONG Tweener::Release(THIS) {
- ULONG UnreleaseObject=fCRef--;
-
- if (fCRef==0)
- delete this; // No reference left, so destroy the object
-
- return UnreleaseObject;
- // local variable used, because fCRef can be destroyed before.
- }
-
- // I3DExtension methods :
- I3DExtension* Tweener::Clone(THIS) {
- Tweener* theClone = new Tweener;
- if (theClone) {
- theClone->AddRef();
- theClone->fData=fData; // copy the TweenerData
- theClone->fCosCoef=fCosCoef;
- theClone->fExpCoef=fCosCoef;
- }
- return theClone;
- }
-
- HRESULT Tweener::ShellUtilitiesInit(THIS_ IShUtilities* shellUtilities) {
- InitCoFailure(shellUtilities);
- return NOERROR;
- }
-
- // I3DExDataExchanger methods :
- ExtensionDataMap* Tweener::GetExtensionDataMap(THIS) {
- return NULL;
- }
-
- void* Tweener::GetExtensionDataBuffer(THIS) {
- return &fData; // used by the shell to set the new parameters
- }
-
- HRESULT Tweener::ExtensionDataChanged(THIS) {
- fCosCoef = 2*M_PI*(fData.fNbOsc+0.25);
- fExpCoef=(double)fData.fExpCoef;
- return NOERROR;
- }
-
- HRESULT Tweener::HandleEvent(THIS_ ULONG SourceID) {
- return ResultFromScode(E_NOTIMPL);
- }
-
- short Tweener::GetResID(THIS) {
- return 144; // this is the view ID in the resource file.
- }
-
- HRESULT Tweener::DoTweening(THIS_ NUM3D& lambda,long time,long time1, long time2) {
- long delta = time2 - time1;
- float t,value;
- if (delta==0) {
- lambda=0;
- return NOERROR;
- }
- t = (1.0*time - time1) / delta;
-
- value = (1-cos(t*fCosCoef)*exp(-t*fExpCoef));
-
- lambda = (double)value;
-
- return NOERROR;
- }
-
- HRESULT Tweener::DoTween (THIS_ IShKeyFrame *res,long time,XTweenerChainLink *alink) {
- return ResultFromScode(E_NOTIMPL);
- }
-
- HRESULT Tweener::Draw (THIS_ IShGraphicDevice *aGD,const LRect *area,const LRect *where) {
- return ResultFromScode(E_NOTIMPL);
- }
-
- HRESULT Tweener::DoValue (THIS_ NUM3D &res,long time,XTweenerChainLink *alink,I3DShTreeElement *tree) {
- return ResultFromScode(E_NOTIMPL);
- }
-
- HRESULT Tweener::DoVector2 (THIS_ VECTOR2D &res,long time,XTweenerChainLink *alink,I3DShTreeElement *tree) {
- return ResultFromScode(E_NOTIMPL);
- }
-
- HRESULT Tweener::DoVector3 (THIS_ VECTOR3D &res,long time,XTweenerChainLink *alink,I3DShTreeElement *tree) {
- return ResultFromScode(E_NOTIMPL);
- }
-
- HRESULT Tweener::DoColor (THIS_ COLOR3D &res,long time,XTweenerChainLink *alink,I3DShTreeElement *tree) {
- return ResultFromScode(E_NOTIMPL);
- }
-
- HRESULT Tweener::DoRotation (THIS_ MATRIX3D &res,long time,XTweenerChainLink *alink,I3DShTreeElement *tree) {
- return ResultFromScode(E_NOTIMPL);
- }
-
-